<template>
<div class="lag-box">
    <el-row class="top-box">
        <el-col :span="8" class="logo-box">
            <img :src="PicLogo" alt class="Logo-pic" />
        </el-col>
        <div class="right">
            <el-col :span="8" class="title-box">
                <div class="title-xian"></div>
                <div class="title">阳光纪检监察智慧监督平台</div>
            </el-col>
            <el-col :span="8" class="user-box">
                <div class="ding-ding">
                    <img :src="PicDing" alt />
                </div>
                <!--
                <div class="head-portrait">
                    <img :src="baseUrl+persionDetail.avatar" alt />
          </div>-->
                <div class="block head-portrait">
                    <el-avatar :size="46">
                        <img :src="baseUrl+persionDetail.avatar" :onerror="defaultImg" />
                    </el-avatar>
                </div>
                <el-dropdown trigger="click" @command="handleCommand">
                    <span class="user-name el-dropdown-link">
                        {{persionDetail.realName}}
                        <i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="1">个人中心</el-dropdown-item>
                        <el-dropdown-item command="2">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-col>
        </div>
    </el-row>

    <el-dialog width="432px" title="退出提示" :visible.sync="deleteAllVisible">
        <i>
            <img src="@/assets/image/Shape.png" alt />
        </i>
        <span>您确定要退出系统？</span>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="returnBack">确 定</el-button>
            <el-button type="cancel" @click="deleteAllVisible = false">取 消</el-button>
        </span>
    </el-dialog>
</div>
</template>

<script>
import avatar from "@/assets/image/Avatar.png";
import utils from "@/utils/utils/index.js";
export default {
    data() {
        return {
            defaultImg: 'this.src="' + avatar + '"',
            PicLogo: require("@/assets/image/logo.png"),
            PicDing: require("@/assets/image/dingdingding.png"),
            persionDetail: {},
            deleteAllVisible: false,
        };
    },
    created() {
        this.getpersonDetail();
    },
    computed: {
        //图片获取根路径
        baseUrl() {
            return this.$store.state.PortalManagement.fileIp;
        },
    },
    methods: {
        getpersonDetail() {
            //             avatar: "group1/M00/00/14/wKgCIl9Qn5iAZhDWAACi5ga3G8g386.jpg"
            // email: "lisi@163.com"
            // loginName: "chenyuchao"
            // orgPath: "集团总部11/集团部门2/岗位2-2"
            // phone: "1300000000"
            // realName: "陈宇超"
            // roleInfo: "超级管理员"
            this.Api.getpersonDetail().then((res) => {
                // console.log(res, "个人信息");
                if (res.code === "0") {
                    this.persionDetail = res.data;
                }
            });
        },
        //设置cookie
        setCookie(c_name, c_pwd, exdays) {
            var exdate = new Date(); //获取时间
            exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); //保存的天数
            //字符串拼接cookie
            window.document.cookie =
                "loginName" + "=" + c_name + ";path=/;expires=" + exdate.toGMTString();
            window.document.cookie =
                "password" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();
        },
        //清除cookie
        //清除cookie
        clearCookie: function () {
            this.setCookie("", "", -1); //修改2值都为空，天数为负1天就好了
        },
        returnBack() {
            //清空Cookie
            this.clearCookie();
            this.Api.getpersonOut().then((res) => {
                this.$router.push({
                    name: "login",
                });
            });
        },
        handleCommand(command) {
            // this.$message.success('click on item ' + command);
            // console.log(command, "command")
            if (command === "2") {
                this.deleteAllVisible = true;
                // console.log(command, "command")
            } else if (command === "1") {
                // console.log(111);
                this.$router.push({
                    name: "Personage",
                });
            }
        },
    },
};
</script>

<style lang="less" scoped>
/**头部整体框架样式 */
.el-row {
    width: 100%;
    height: 92px;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0px 1px 4px 0px rgba(0, 21, 41, 0.12);
}

/**头部图片logo */

.logo-box {
    width: 106px;
    margin: 0 0px 0 10px;
    height: 92px;
    padding: 10px 10px 10px 10px;
}

.title-xian {
    width: 1px;
    height: 27px;
    background: rgba(0, 33, 64, 1);
    margin-top: 34px;
}

.title-box {
    display: flex;
    width: 500px;
}

.title {
    font-size: 34px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: rgba(0, 33, 64, 1);
    margin-left: 19px;
    line-height: 90px;
}

.user-box {
    text-align: right;
    height: 92px;
    display: flex;
    align-items: center;
    overflow: hidden;
    margin-right: 18px;
    display: flex;
    justify-content: flex-end;
    align-items: center;

    .ding-ding {
        margin-right: 20px;
        cursor: pointer;
        border-right: 1px solid #dddddd;
        height: 24px;
        padding-right: 20px;

        img {
            line-height: 24px;
        }
    }
}

/**下拉菜单 */
.el-icon-arrow-down {
    font-size: 12px;
}

.demonstration {
    display: block;
    color: #8492a6;
    font-size: 14px;
    margin-bottom: 20px;
}

.el-dropdown-link {
    cursor: pointer;
    color: #409eff;
}

.head-portrait {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    margin-right: 8px;
    overflow: hidden;

    img {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 100%;
    }
}

/deep/.user-name {
    display: inline-block;
    font-size: 18px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
    margin-right: 0;
}

.right {
    display: flex;
    justify-content: space-between;
}

.top-box,
.lag-box {
    height: 92px;
}

// 弹窗的样式
/deep/.el-button--deleteAll {
    width: 80px;
    height: 36px;
    background: rgba(255, 255, 255, 1);
    border-radius: 3px;
    border: 1px solid rgba(251, 54, 63, 1);
    padding: 0;
    color: #fb363f;
}

/deep/.el-dialog {
    margin-top: 19% !important;
    box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.15);
    border-radius: 4px;

    >.el-dialog__header {
        padding-left: 70px;
        padding-bottom: 0;
        text-align: left;

        >span {
            font-size: 16px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: rgba(0, 0, 0, 0.85);
            line-height: 24px;
        }
    }

    >.el-dialog__body {
        padding-left: 70px;
        padding-top: 12px;
        padding-bottom: 24px;
        position: relative;
        text-align: left;

        >i {
            position: absolute;
            left: 32px;
            top: -22px;
        }

        >span {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(102, 102, 102, 1);
        }
    }

    >.el-dialog__footer {
        .el-button--primary {
            width: 65px;
            height: 32px;
            background: rgba(22, 119, 255, 1);
            padding: 0;
            color: white;
        }

        .el-button--cancel {
            width: 65px;
            height: 32px;
            background: rgba(250, 250, 250, 1);
            border: 1px solid rgba(221, 221, 221, 1);
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(102, 102, 102, 1);
            padding: 0;
            margin-left: 8px;
        }
    }
}
</style>
